import React, { Component } from 'react';
import { Route, Switch } from 'react-router-dom'
import { Row, Col, Affix } from 'antd';
import List from '../../components/List/List';
import styles from './index.module.css';
import MyInput from '../../components/Input/input';
import NewsRecommend from '../../components/newsRecommend/newsRecommend';
import UsersRecommend from '../../components/usersRecommend/usersRecommend';
import IndexMain from '../../components/indexMain';
import User from "../../components/indexMain/indexUser/indexUser";
import TweetDetail from "../../components/indexMain/tweetDetail";

// let searchAttention = []
export default class Index extends Component {
  // state = {
  //   userMessages: [],
  // }
  // componentDidMount() {
  //   async function some() {
  //     console.log('some');
  //     await post('/api/searchAttention', { _id }).then(res => {
  //       console.log(JSON.parse(res.data.data.allAttention), '----');
  //       searchAttention = JSON.parse(res.data.data.allAttention)
  //     })
  //   }
  //   some()
  // }
  
  render() {
    return (
      <div className={styles.content}>
        <div className={styles.row}>
          <Row >
            <Col span={7}>
              <MyInput isRadius={true} delay={1000} size={5}></MyInput>
              {/* 需要传 isRadius delay防抖时间 */}
              <Affix offsetTop={45}>
                <div>
                  <NewsRecommend ></NewsRecommend>
                  <UsersRecommend></UsersRecommend>
                </div>
              </Affix>

            </Col>
            <Col span={12} >
              <Switch>
                <Route exact path={"/index/:user"} component={User}></Route>
                <Route exact path={"/index/:user/:msgID"} component={TweetDetail}></Route>
                <Route path={"/index"} component={IndexMain}></Route>
              </Switch>
            </Col>
            <Col span={5} ><List /></Col>
          </Row>
        </div>
      </div>
    )
  }
}


